Add support for multiple context types mixins#137
Open
chpill wants to merge 2 commits intotonsky:gh-pagesfrom
Open
Add support for multiple context types mixins#137chpill wants to merge 2 commits intotonsky:gh-pagesfrom
chpill wants to merge 2 commits intotonsky:gh-pagesfrom
Conversation
Contributor
martinklepsch
left a comment
There was a problem hiding this comment.
I think it's a worthy addition, context can be a useful tool but for that it needs to be composable.
Great to see you're using derivatives also 🙂
| :childContextTypes | ||
| (when-not (empty? child-context-types) | ||
| (clj->js (apply merge child-context-types)))} | ||
|
|
Contributor
There was a problem hiding this comment.
Using a merge here that warns (or throws even) on conflicts would be good I think. This way using 3rd party mixins is "safe" and free from surprises.
Author
There was a problem hiding this comment.
I think you are right, it should probably throw in there. If the user really wants to override the context types put there by mixins, he can still do it with a {:class-properties {:contextTypes ... }} map that will override everything.
Also, thanks a lot for the derivatives library!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implementation to illustrate my suggestion on #136
It works, using
child-context-typesandcontext-typesto aggregate the different types correctly. But you have to be careful not to have a{:class-properties {:context-types ...}}in one of your mixins, as it will be applied last and override whatever you had in the top level:context-types(idem for:child-context-types)